#include "StringFunctions.h"
#include <iostream>

using std::string;
using std::cout;


// takes a string and returns a vector of whitespace deliniated characters within that string
vector<string> split(const string& s){
    vector<string> ret;
    typedef string::size_type string_size;
    string_size i = 0;

    while( i !=s.size()){
        //ignore leading blanks
        while(i != s.size() && isspace(s[i])) ++i;

        //find the end of the next word
        string_size j = i;

        while (j != s.size() && !isspace(s[j])) ++j;

        //if you find non-whitespace characters (words)
        if (i != j){

            //copy from s starting at i and taking j-a chars
            ret.push_back(s.substr(i, j-i));
            i = j;

        }
    }

    //return a vector of strings containing words
    return ret;

}


